package com.hx.er.action.admin.settings;

import org.springframework.beans.factory.annotation.Autowired;

import com.hx.er.action.base.ErAdminAction;
import com.hx.er.bean.detail.StreetDetailBean;
import com.hx.er.service.admin.IAdminSettingsService;

public class AdminStreetReviveAction extends ErAdminAction {
	// 序列化ID
	private static final long serialVersionUID = 4236711711899386403L;

	private long streetId;
	private long districtId;
	private long cityId;
	private StreetDetailBean streetDetailBean;

	@Autowired
	private IAdminSettingsService adminSettingsService;

	public String init() {
		this.initPage();
		return SUCCESS;
	}

	public String revive() {
		this.streetDetailBean.setStreetId(this.streetId);
		this.streetDetailBean.setUpdateUserId(super.getUserInfoLogin().getUserId());

		int count = this.adminSettingsService.reviveStreet(this.streetDetailBean);

		if (count == 0) {
			this.initPage();
			this.addActionError(super.getText(REVIVE_FAILURE_MSG));
			return INPUT;
		} else {
			// 缓存中加入该街道
			this.addActionMessage(super.getText(REVIVE_SUCCESS_MSG));
			return SUCCESS;
		}
	}

	private void initPage() {
		// 查询餐馆信息
		this.streetDetailBean = this.adminSettingsService.getStreetDetailById(this.streetId);
	}

	public long getStreetId() {
		return streetId;
	}

	public void setStreetId(long streetId) {
		this.streetId = streetId;
	}

	public long getDistrictId() {
		return districtId;
	}

	public void setDistrictId(long districtId) {
		this.districtId = districtId;
	}

	public long getCityId() {
		return cityId;
	}

	public void setCityId(long cityId) {
		this.cityId = cityId;
	}

	public StreetDetailBean getStreetDetailBean() {
		return streetDetailBean;
	}

	public void setStreetDetailBean(StreetDetailBean streetDetailBean) {
		this.streetDetailBean = streetDetailBean;
	}

}
